import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:sp_util/sp_util.dart';
import '../theme/theme.dart';


class MainStore extends GetxController {

    List<ThemeItem> allTheme=MyTheme.getThemeList();
    ThemeData currentTheme=MyTheme.normal;

	bool isLogin=false;


    @override
  	onInit()async {
        await SpUtil.getInstance();
        String? key=SpUtil.getString('currentTheme');
        if(key!=null&&key.isNotEmpty){
            currentTheme=allTheme.firstWhere((element) => element.key==key).theme;
        }
        super.onInit();
    }

    ///修改主题
    changeTheme(String themeKey){
		ThemeData theme=allTheme.firstWhere((element) => element.key==themeKey).theme;
        currentTheme=theme;
		SpUtil.putString('currentTheme', themeKey);
        update();
    }
}
